package com.cn.springcloudwechat.service.weixin;


import com.cn.springcloudwechat.common.utils.weixin.api.WechatAPI;
import com.cn.springcloudwechat.common.utils.weixin.api.WechatAPIImpl;
import com.cn.springcloudwechat.common.utils.weixin.util.ConfigReader;
import com.cn.springcloudwechat.common.utils.weixin.vo.MPAccount;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;


@Service("WXJsAuthService")
public class WXJsAuthServiceShareImp  implements WxJsAuthShareService {
protected static WechatAPI ua;
	
	protected static ConfigReader _cr;
	
    protected MPAccount mpAct;
	
    protected static String accessToken;
    
    @PostConstruct
	public void init() {
		_cr = new ConfigReader("/weixin/mp.properties");
		mpAct = new MPAccount();
		mpAct.setMpId(_cr.get("mpId"));
		mpAct.setAppId(_cr.get("appId"));
		mpAct.setAppSecret(_cr.get("appSecret"));
		mpAct.setAESKey(_cr.get("aseKey"));
		accessToken = _cr.get("accessToken");
		ua = WechatAPIImpl.create(mpAct);
	}

	@Override
	public String getJsTicket(String Url, MPAccount mpa) {
		init();
		String ticket = ua.getJSTicket();
		return ticket;
	}

}
